home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / external / widstub / widget_arrowb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-08  |  2.6 KB  |  100 lines

  1. /*
  2.  *    $Id: widget_arrowb.c,v 1.1 1995/07/21 18:04:00 ali Exp $
  3.  *                                    6 August 1993, AB, RSI
  4.  *
  5.  * arrowb.c - This file contains C code to be called from VMS IDL via
  6.  * CALL_EXTERNAL. It uses the IDL stub widget to add a Motif
  7.  * ArrowButton to an IDL created widget hierarchy. The button issues
  8.  * a WIDGET_STUB_EVENT every time the button is released.
  9.  *
  10.  *                       11 April 1995
  11.  * Fixed failure to call widget_set_stub_ids(). This was OK in
  12.  * previous IDLs, but IDL 4.0 uses those variables for geometry
  13.  * management.
  14.  *
  15.  * Converted to new IDL 4.0 API.
  16.  */
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <X11:keysym.h>         /* Keysyms for text widget events */
  21. #include <X11:Intrinsic.h>
  22. #include <X11:StringDefs.h>
  23. #include <X11:Shell.h> 
  24. #include <Xm:ArrowB.h>
  25.  
  26. #include "idl_dir:[external]export.h"
  27.  
  28.  
  29. /*ARGSUSED*/
  30. static void arrowb_CB(Widget w, caddr_t client_data, caddr_t call_data)
  31. {
  32.   char *rec;
  33.   XmArrowButtonCallbackStruct *abcs;
  34.  
  35.  
  36.   IDL_WidgetStubLock(TRUE);
  37.  
  38.   if (rec = IDL_WidgetStubLookup((unsigned long) client_data)) {
  39.     abcs = (XmArrowButtonCallbackStruct *) call_data;
  40.     IDL_WidgetIssueStubEvent(rec, abcs->reason == XmCR_ARM);
  41.   }
  42.  
  43.   IDL_WidgetStubLock(FALSE);
  44. }
  45.  
  46.  
  47.  
  48. static void arrowb_size_func(int stub, int width, int height)
  49. {
  50.   char *stub_rec;
  51.   unsigned long t_id, b_id;
  52.  
  53.  
  54.   IDL_WidgetStubLock(TRUE);
  55.  
  56.   if (stub_rec = IDL_WidgetStubLookup(stub)) {
  57.     IDL_WidgetGetStubIds(stub_rec, &t_id, &b_id);
  58.     printf("Setting WIDGET %d to width %d and height %d\n", stub, width,height);
  59.     XtVaSetValues((Widget) b_id, XmNwidth, width, XmNheight, height, NULL);
  60.   }
  61.  
  62.   IDL_WidgetStubLock(FALSE);
  63. }
  64.  
  65.  
  66.  
  67. int widget_arrowb(IDL_LONG parent, IDL_LONG stub, int use_own_size_func)
  68. {
  69.   Widget parent_w;
  70.   Widget stub_w;
  71.   char *parent_rec;
  72.   char *stub_rec;
  73.   unsigned long t_id, b_id;
  74.  
  75.  
  76.   IDL_WidgetStubLock(TRUE);
  77.  
  78.   if ((parent_rec = IDL_WidgetStubLookup(parent))
  79.       && (stub_rec = IDL_WidgetStubLookup(stub))) {
  80.     /* Bottom widget of parent is parent to arrow button */  
  81.     IDL_WidgetGetStubIds(parent_rec, &t_id, &b_id);
  82.     parent_w = (Widget) b_id;
  83.  
  84.     stub_w = XtVaCreateManagedWidget("arrowb", xmArrowButtonWidgetClass,
  85.                      parent_w, NULL);
  86.  
  87.     IDL_WidgetSetStubIds(stub_rec, (unsigned long) stub_w,
  88.              (unsigned long) stub_w);
  89.     XtAddCallback(stub_w, XmNarmCallback, (XtCallbackProc) arrowb_CB,
  90.                   (XtPointer) stub);
  91.     XtAddCallback(stub_w, XmNdisarmCallback, (XtCallbackProc) arrowb_CB,
  92.                   (XtPointer) stub);
  93.  
  94.     if (use_own_size_func) IDL_WidgetStubSetSizeFunc(stub_rec,arrowb_size_func);
  95.   }
  96.  
  97.   IDL_WidgetStubLock(FALSE);
  98.   return stub;
  99. }
  100.